#if !defined(__APP_SERIAL_H__)
#define __APP_SERIAL_H__

#include "app_device.h"
#include "app_message.h"
#include <termios.h>

typedef enum
{
    BaudRate_9600 = B9600,
    BaudRate_115200 = B115200,
} SerialBaudRate;

typedef enum
{
    Parity_None = 0,
    Parity_Odd = PARENB | PARODD,
    Parity_Even = PARENB,
} SerialParity;

typedef enum
{
    OneStopBit = 0,
    TwoStopBits = CSTOPB,
} SerialStopBits;

typedef struct
{
    Device super;
    SerialBaudRate baud_rate;
    SerialParity parity;
    SerialStopBits stop_bits;
} SerialDevice;

SerialDevice *app_serial_init(char *filename);

int app_serial_setBaudRate(SerialDevice *serial_device, SerialBaudRate baud_rate);

int app_serial_setParity(SerialDevice *serial_device, SerialParity parity);

int app_serial_setStopBits(SerialDevice *serial_device, SerialStopBits stop_bits);

int app_serial_setConnectionType(SerialDevice *serial_device, ConnectionType connection_type);

#endif // __APP_SERIAL_H__
